import {defineStore} from "pinia";
// @ts-ignore
import cookie from 'js-cookie'

export const useStore = defineStore("token", {
    state: () => {
        return {
            token: '',
            key: '',
            user: {}
        }
    },
    getters: {},
    actions: {
        setToken(token: string) {
            this.token = token
            cookie.set("token", token)
        },
        //将接收的消息保存到cookie中
        setKey(key: string) {
            this.key = key
            cookie.set("key", key)
        }
    }
})